﻿using System.Collections.Generic;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;

namespace Sample.ItemsControl
{
  public class WinItemsControlViewModel
  {
    private List<string> _items;
    private List<UcItemsControlViewModel> _itemsUc;

    private RelayCommand _populateCommand;

    public List<string> Items
    {
      get { return _items; }
      set { _items = value; }
    }

    public List<UcItemsControlViewModel> ItemsUc
    {
      get { return _itemsUc; }
      set { _itemsUc = value; }
    }

    public WinItemsControlViewModel()
    {
      Items = new List<string> { "One", "Two", "Tree" };

      ItemsUc = new List<UcItemsControlViewModel>
      {
        new UcItemsControlViewModel("One"),
        new UcItemsControlViewModel("Two"),
        new UcItemsControlViewModel("Tree"),
      };
    }

    public RelayCommand PopulateCommand
    {
      get
      {
        return _populateCommand ?? (_populateCommand = new RelayCommand(ExecutePopulateCommand));
      }
    }

    public void ExecutePopulateCommand()
    {
      ItemsUc = new List<UcItemsControlViewModel>
      {
        new UcItemsControlViewModel("One"),
        new UcItemsControlViewModel("Two"),
        new UcItemsControlViewModel("Tree"),
      };
    }
  }
}
